module;
#include <Windows.h>

module exports:Window;

namespace yichu {
	Window::Window()
	{

	}

	Window::Window(HWND hwnd) :hwnd(hwnd)
	{
	}

	Window::~Window()
	{
	}
	void Window::setHwnd(HWND hwnd)
	{
		this->hwnd = hwnd;
	}
	void Window::setAlpha(BYTE alpha)
	{
		DWORD style = GetWindowLongPtrA(hwnd, GWL_EXSTYLE);
		style |= WS_EX_LAYERED;
		SetWindowLongPtrA(hwnd, GWL_EXSTYLE, style);
		SetLayeredWindowAttributes(hwnd, 0, alpha, LWA_ALPHA);
		UpdateWindow(hwnd);
	}
	HWND Window::getHwndByCursor()
	{
		// ???????λ??
		POINT pt;
		if (GetCursorPos(&pt))
		{
			HWND hwnd = WindowFromPoint(pt);
			return hwnd;
		}
		else
		{
			return nullptr;
		}
	}
}

